@tool
# @tool表示编辑器即可运行的某些脚本
# 1. 开启警告 _get_configuration_warnings
# 2. Engine.is_editor_hint() 表示只在编辑器运行
extends Sprite2D

@export var title = "":
	set(p_title):
		if p_title != title:
			title = p_title
			update_configuration_warnings()

@export var description = "":
	set(p_description):
		if p_description != description:
			description = p_description
			update_configuration_warnings()

var direction :int	= 1
	
func _get_configuration_warnings():
	var warnings = []
	if title == "":
		warnings.append("Please set `title` to a non-empty value.")

	if description.length() >= 100:
		warnings.append("`description` should be less than 100 characters long.")

	# Returning an empty array means "no warning".
	return warnings
	
func _process(delta):
	if Engine.is_editor_hint():
		#if rotation > PI/4:
			#direction = -1
		#if rotation < -PI/4: 
			#direction = 1 
		#rotation +=  PI * delta * direction
		pass
	else:
		if rotation > PI/9:
			direction = -1
		if rotation < -PI/9: 
			direction = 1 
		rotation +=  PI * delta * direction
